<html style="overflow: hidden;">
    <head>
        <meta charset="utf-8">
        <link rel="stylesheet" type="text/css" href="/static/new_ui/new_css/bootstrap.css">
        <link rel="stylesheet" type="text/css" href="/static/new_ui/new_css/base_v3.0.css">
        <link rel="stylesheet" type="text/css" href="/static/new_ui/css/upload.css">
        <link rel="stylesheet" type="text/css" href="/static/libs/easyui/themes/default/easyui.css">
        <link rel="stylesheet" type="text/css" href="/static/libs/easyui/themes/icon.css">

        <style type="text/css">
        /* 用于冲掉样式表中样式，只是借用这个名字显示错误信息 */
        .in-text2{margin-top: 0px;padding-left:0px;width: auto;height: auto;}
        .input-cont2{height:auto}
        .button.btn-multi{background-color:#E1E6E5;border-bottom-color:#B3B6B6;color: gray}
        .button.btn-multi:hover{background-color:#E1E6E5;border-bottom-color:#B3B6B6;color: gray}
        .button.btn-multi:active{background-color:#E1E6E5;border-bottom-color:#B3B6B6;color: gray}

        </style>

</head>
<body class="white-bg">
    <form id="form_task" style="padding: 0">
        <div class="container-fluid warp tops">
            <h1 class="page-headers no-icon">
                <img onclick="history.back();" style="cursor: pointer;" class="gift-back" src="/static/new_ui/images/page-headers.png" alt=""/>新建软文
            </h1>
            <div class="row-fluid header-show">
                <div class="show-img" style="">
                    <span class="show-ico page-header-show">
                        <span class="show-info" >
                            <i></i>
                            <h3>案例效果:</h3>
                            <img src="/static/new_ui/images/new_soft_text_tip.jpg" alt=""/>
                        </span>
                    </span>
                </div>
                <div class="tab-pane fade in active">
                    <span class="chip-font2"><strong>软文内容编辑：</strong></span>
                    <div class="input-cont2 new-soft-line" id="taskNamewrongDiv">
                        <span class="new-soft-text">软文标题：</span>
                        <textarea name="name" tip="软文标题" onkeyup="validateInput(this,'taskName',30,'软文标题')" id="taskName" class="in-text2 soft-title-input"></textarea>
                        <span class="soft-title-number"><b id="taskNamewronglength" style="font-weight:normal">0</b>/<b style="font-weight:normal">30</b></span>
                        <span id="taskNamewrong" style="height: 17px;font-size: 12px;color: #ea3a3c;position: absolute;padding-left: 10px;bottom: 0px;"></span>
                    </div>
                    <div class="input-cont2 new-soft-line" id="postPicwrongDiv">
                        <span class="new-soft-text">列表图片：</span>
                        <a data-toggle="modal" href="#uploadImgPopup" style="position:relative;" id="uploadbtn">
                            <button type="button" class="button btn-gray btn-w100 margin0">上传</button>
                            <span class="in-text2 upload-pic-box" style="width:98px;height:38px;position:absolute;left:0;">
                                <i class="upload-pic-btn naryou-upload upload-pic post-pic" style="width:100px;height:40px;border:none;background:none;" candelete="deleteValue" required="true" data-options="{uploadUrl:'/upload/BUILDING_TASK/img/', canCrop: true, cropWidth: 600,optionType:0, cropHeight:390,size:1048576}">
                                    <input type="hidden" name="imageUrl" id="posterPic" class="path" value=""/> 
                                    <img id="postPic" src="" style="display: none;">
                                </i>
                            </span>
                        </a>
                        <span id="postPicwrong" style="height: 17px;font-size: 12px;color: #ea3a3c;position: absolute;padding-left: 0px;bottom: 20px;"></span>
                        <span class="add-gift-explain"> (图片建议尺寸:600像素*390像素，支持JPG、PNG、JPEG、GIF格式，大小限制在1024k以内)</span>
                        <div class="addGift-img none" style="margin-left:80px;">
                            <img id="imgPic" src=""/>
                        </div>
                        <input type="hidden" name="imageShow" value="1"> 
                    </div>
                    <div class="new-soft-line">
                        <span class="new-soft-text">内容详情：</span>
                        <div class="radios-module custom-ulp show-mode">
                            <a onclick="setDisplayType('BASIC_TEMPLATE')" class="radios first-radio current base-ra"
                               href="javascript:void(0);"><span></span>&nbsp;<span>基础模板</span></a>
                            <span class="show-ico" style="left:-25px;">
                                <span class="show-info" style="top:-150px">
                                    <i></i>
                                    <h3>案例效果：</h3>
                                    <img src="/static/new_ui/images/soft_text_basic.jpg" alt=""/>
                                </span>
                            </span>
                            <a onclick="setDisplayType('MULTIMEDIA_ANIMATION')" class="radios second-radio FChoose chip-radio2 media-ra"
                               href="javascript:void(0);"><span></span>&nbsp;<span>幻灯片</span></a>
                            <span class="show-ico" style="left:-20px;">
                                <span class="show-info" style="top:-150px;">
                                    <i></i>
                                    <h3>案例效果：</h3>
                                    <img src="/static/new_ui/images/soft_text_multimedia.jpg" alt=""/>
                                </span>
                            </span>
                            <input type="hidden" name="taskDisplayType" id="taskDisplayType" value="BASIC_TEMPLATE">
                        </div>
                        <!---基础版------->
                        <div class="input-cont2 base-template" id="editorwrongDiv">
                            <script type="text/plain" class="in-text2 " id="editor" name="content"></script>
                            <span id="editorwrong" style="height: 17px;font-size: 12px;color: #ea3a3c;position: absolute;padding-left: 490px;bottom: 0px;width: 200px;"></span>
                            
                            <a href="javascript:void(0);" class="preview-result" style="bottom: 15px;right: -110px;" id="basicPreShow">预览微官网效果</a>
                        </div>
                        <!---多媒体版-------->
                        <div class="media-template none">
                            <span class="new-soft-text">图片：</span>
                            <a data-toggle="modal" href="#uploadImgPopup" style="position:relative;">
                                <button onclick="selectMultiPic()" type="button" class="button btn-gray btn-w100 margin0 btn-multi">添加图片</button>
                                <span class="upload-pic-box" style="width:100px;height:40px;position:absolute;left:0;display: none;">
                                    <i class="upload-pic-btn naryou-upload upload-pic multi-pic" style="width:100px;height:40px;border:none;background:none;" candelete="deleteValue" required="true" data-options="{uploadUrl:'/upload/MULTI_MEDIA/img/', canCrop: true, cropWidth: 600,optionType:1, cropHeight:1000,size:1048576}">
                                        <input type="hidden" id="multiPic" class="path" value=""/> 
                                    </i>
                                </span>
                            </a>
                            <span class="add-gift-explain"> (图片建议尺寸:600*1000，支持JPG、PNG、JPEG、GIF格式，大小不超过1024k。)</span>
                            <div class="input-cont2 " id="multiPicwrongDiv">
                                <div class="in-text2 media-template-box">
                                    <table>
                                        <tr id="picList"></tr>
                                    </table>
                                </div>
                                <span id="multiPicwrong" style="height: 17px;font-size: 12px;color: #ea3a3c;position: absolute;padding-left: 10px;bottom: 0px;width: 200px;"></span>
                                
                                <a href="javascript:void(0);" class="preview-result2" style="bottom: 15px;right: -90px;" id="mediaPreShow">预览微官网效果</a>
                            </div>
                            <div class="dynamic-effect">
                                <span class="new-soft-text" style="display: inline-block;margin-top: -70px;">动态效果：</span>
                                <p class="radios-module custom-ulp show-mode" style="width: 550px;display: inline-block;">
                                    <a class="radios first-radio current " effect="FIRST"
                                       href="javascript:void(0);"><span></span>&nbsp;<span>纵向特效1</span></a>
                                    <a class="radios second-radio FChoose chip-radio2" effect="SECOND"
                                       href="javascript:void(0);"><span></span>&nbsp;<span>纵向特效2</span></a>
                                    <a class="radios second-radio FChoose chip-radio2" effect="THIRD"
                                       href="javascript:void(0);"><span></span>&nbsp;<span>纵向特效3</span></a>
                                    <a class="radios second-radio FChoose chip-radio2" effect="FOURTH"
                                       href="javascript:void(0);"><span></span>&nbsp;<span>纵向特效4</span></a>
                                    <a class="radios second-radio FChoose chip-radio2" effect="FIFTH"
                                       href="javascript:void(0);"><span></span>&nbsp;<span>横向特效1</span></a>
                                    <a class="radios second-radio FChoose chip-radio2" effect="SIXTH"
                                       href="javascript:void(0);"><span></span>&nbsp;<span>横向特效2</span></a>
                                    <a class="radios second-radio FChoose chip-radio2" effect="SEVENTH"
                                       href="javascript:void(0);"><span></span>&nbsp;<span>横向特效3</span></a>
                                    <a class="radios second-radio FChoose chip-radio2" effect="EIGHTH"
                                       href="javascript:void(0);"><span></span>&nbsp;<span>横向特效4</span></a>


                                    <input type="hidden" name="dynamicEffect" value="FIRST" id="dynamicEffect"> 
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="tab-pane fade in active">
                    <span class="chip-font2"><strong>推广按钮设置</strong>
                        <span class="add-gift-explain">(客户点击后跳转到微官网)</span>
                        <span class="soft-wen-icon">
                            <span class="show-ico">
                                <span class="show-info" style="top:-150px">
                                    <i></i>
                                    <h3>案例效果：</h3>
                                    <img src="/static/new_ui/images/popularize_button.jpg" alt=""/>
                                </span>
                            </span>
                        </span>
                    </span>
                    <div class="new-soft-line">
                        <span class="new-soft-text">链接页面：</span>
                        <div class="dropdown-list" style="display:inline-block;width:218px;height: 28px;">
                            <div class="drop-list input-cont2" style="width:218px;height: 28px;" id="linkShowwrongDiv">
                                <div class="checked in-text2" style="width:450px;height: 28px;">
                                     
                                    
                                        
                                        
                                            
                                            
                                        
                                    
                                        
                                        
                                    
                                        
                                        
                                    
                                        
                                        
                                    
                                        
                                        
                                    
                                        
                                        
                                    
                                        
                                        
                                    
                                    <input tip="链接地址" placeholder="可以链接到微官网任何页面或者外部任何页面，将页面网址复制粘贴在此处" onkeyup="validateUrl(this,'linkShow',250,'链接地址')" style="color: rgb(173, 176, 176);width: 474px;margin-left: -12px;border: none;height: 28px;padding-right: 30px;background-color: rgb(255, 255, 255);" type="text" value="" id="linkShow">
                                    <span id="linkShowwrong" style="height: 17px;font-size: 12px;color: #ea3a3c;position: absolute;padding-left: 10px;bottom: 5px;left: 480px;width: 200px;"></span>
                                    <span></span>
                                    <input type="hidden" name="wapLinkUrl" id="wapLinkUrl" value="/">
                                    <input type="hidden" name="otherLinkUrl" id="otherLinkUrl" value="">
                                    <input type="hidden" name="articleLinkType" id="articleLinkType" value="WAP"> 
                                </div>
                            </div>
                            <ul class="select select-min none" style="width:474px;margin-top:1px;border-top:none;">
                                
                                    <li><a onclick="chooseLink(this);" href="javascript:void(0);" style="color:#ADB0B0" value="/">微官网首页</a></li>
                                
                                    <li><a onclick="chooseLink(this);" href="javascript:void(0);" style="color:#ADB0B0" value="/building.htm">楼盘概况</a></li>
                                
                                    <li><a onclick="chooseLink(this);" href="javascript:void(0);" style="color:#ADB0B0" value="/building/buildingselling">户型鉴赏</a></li>
                                
                                    <li><a onclick="chooseLink(this);" href="javascript:void(0);" style="color:#ADB0B0" value="/template/">样板间</a></li>
                                
                                    <li><a onclick="chooseLink(this);" href="javascript:void(0);" style="color:#ADB0B0" value="/albums">楼盘相册</a></li>
                                
                                    <li><a onclick="chooseLink(this);" href="javascript:void(0);" style="color:#ADB0B0" value="/news">最新动态</a></li>
                                
                                    <li><a onclick="chooseLink(this);" href="javascript:void(0);" style="color:#ADB0B0" value="http://mp.weixin.qq.com/s?__biz=MjM5NjMyNTczNg==&mid=203830532&idx=1&sn=53d357ac9160b35f6eaf0d45ed6ed648#rd">关注微信公众号</a></li>
                                
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="input-cont2 tab-pane fade in active" id="moneywrongDiv">
                    <span class="chip-font2"><strong>客户分享到各社交平台可获得的购房币数量：</strong></span><br>
                    <input type="text" tip="购房币数量" onkeyup="validateInput(this,'money',6,'购房币数量')" name="money" id="money" value="" class="in-text2 marginL20 w220"/>
                    <span id="moneywrong" style="height: 17px;font-size: 12px;color: #ea3a3c;position: absolute;padding-left: 10px;bottom: 0px;"></span>
                </div>
                <div class="tab-pane fade in active">
                    <span class="chip-font2"><strong>音乐配置：</strong>
                        <a href="javascript:void(0)"><span id="needMusicSpan" onclick="checkMusicUrlDiv(this)" class="baseSet-close"></span></a>
                        <input type="hidden" id="needMusic" value="0" name="needMusic">
                    </span>
                    <div id="musicDiv" style="display: none;width: 500px;margin-top: 10px;border: solid 1px #ffffff;position: relative;margin-left: 5px;padding-left: 10px;padding-bottom: 5px;">
                        <a class="button btn-gray btn-w120 btn-h30" style="margin: 10px 0 15px 0;" href="javascript:void(0);" onclick="uploadMusic()">上传音乐文件</a>
                        <span style="display: none" id="upload-music"></span>
                        <p class="tab-head"><em class="em1">已上传的音乐</em><em class="tishi">（最多10首，每首音乐文件最大不能超多5M）</em></p>
                        <div class="music_list">
                            <ul class="music_ul clearFix" id="music_list">
                                
                            </ul>
                            <input type="hidden" id="musicChooseId" name="musicChooseId" value="">
                            <input type="hidden" id="musicUrl" name="musicUrl" value="">
                            <span id="musicDivwrong" style="height: 17px;font-size: 12px;color: #ea3a3c;position: absolute;padding-left: 10px;bottom: -5px;left: 500px;width: 200px;"></span>
                        </div>
                    </div>
                </div>
                <div class="tab-pane fade in active">
                    <span class="chip-font2"><strong>分享到朋友圈的展示内容</strong>
                        <span class="soft-wen-icon">
                            <span class="show-ico">
                                <span class="show-info" style="top:-150px">
                                    <i></i>
                                    <h3>案例效果：</h3>
                                    <img src="/static/new_ui/images/show-info-img02.jpg" alt=""/>
                                </span>
                            </span>
                        </span>
                    </span>
                    <div class="input-cont2 wrong new-soft-line share-friend" id="shareTitlewrongDiv" style="min-width: 0px;">
                        <a data-toggle="modal" href="#uploadImgPopup" style="position:relative;">
                            <img class="share-friend-img" style="visibility: hidden;" src="" alt="" id="sharePicShow"/>
                            <span class="upload-pic-box" style="width:80px;height:80px;position:absolute;left:0;" id="sharePicSpan">
                                <i class="upload-pic-btn naryou-upload upload-pic share-pic" style="width:80px;height:80px;border:none;" candelete="deleteValue" required="true" data-options="{uploadUrl:'/upload/INVITETASK/img/', canCrop: true, cropWidth: 400,optionType:3, cropHeight:400,size:1048576}">
                                    <input type="hidden" name="sharePic" id="sharePic" class="path" value=""/> 
                                    <img src="" id="share-pic" >
                                </i>
                            </span>
                        </a>
                        <textarea name="shareTitle" tip="分享标题" onkeyup="validateInput(this,'shareTitle',26,'分享标题')" id="shareTitle" class="share-friend-text" placeholder="分享标题"></textarea>
                        <span class="text-limit"><b id="shareTitlewronglength" style="font-weight:normal">0</b>/<b style="font-weight:normal">26</b></span>
                        <span id="shareTitlewrong" style="height: 17px;font-size: 12px;color: #ea3a3c;position: absolute;padding-left: 10px;bottom: 10px;left: 500px;width: 240px;"></span>
                    </div>
                </div>
                <div style="display: none" id="multiPicList"></div> 
                <input type="hidden" id="realIndex">
                <div class="add-button">
                    <a class="button btn-success btn-w100 margin0" href="javascript:void(0);" onclick="saveTask();">保存</a>
                    <a class="button btn-gray btn-w100" href="javascript:history.back();">取消</a>
                </div>

            </div>
        </div>
    </form>
    <!--删除歌曲弹出层-->
    <div id="delete" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-body">
            <div class="pass-hint">
                <p class="hint-con" style="color:#767982;font-size:24px">是否删除该音乐？</p>
                <p style="text-align:center;color:#757881;font-size:14px;padding-right:20px"><span>音乐:</span><span id="musicName">圣诞快乐.MP3</span></p>
                <input type="hidden" id="musicId">
            </div>
        </div>
        <div class="modal-footer" style="width: 224px;margin: 0 auto;">
            <button class="button btn-caution btn-w100" onclick="submitDel()">是</button>
            <button class="button btn-gray btn-w100" data-dismiss="modal" aria-hidden="true">否</button>
        </div>
    </div>
</body>


<script type="text/javascript" src="/static/new_ui/new_js/jquery.js"></script>
<script type="text/javascript" src="/static/new_ui/new_js/build.js"></script>
<script type="text/javascript" src="/static/new_ui/new_js/bootstrap.min.js"></script>
<script type="text/javascript" src="/static/new_ui/new_js/base_v3.0.js"></script>
<script type="text/javascript" src="/static/new_ui/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="/static/new_ui/js/ueditor/ueditor.all.js"></script>
<script type="text/javascript" src="/static/libs/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/static/libs/easyui/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="/static/new_ui/js/naryouuploadx_temp.js"></script>
<script type="text/javascript" src="/static/new_ui/js/jquery.Jcrop.js"></script>
<script type="text/javascript" src="/static/new_ui/js/base.js"></script>
<script type="text/javascript" src="/static/new_ui/js/naryouuploadx_temp_music.js"></script>

<script type="text/javascript">
$(function(){
    $(".base-ra").click(function(){
        $(".media-template").addClass("none");
        $(".base-template").removeClass("none");
    });
    $(".media-ra").click(function(){
        $(".media-template").removeClass("none");
        $(".base-template").addClass("none");
    });
    $("#needMusicSpan").click(function(){
        $(this).hasClass("baseSet-open") ? $(this).removeClass("baseSet-open").addClass("baseSet-close") : $(this).removeClass("baseSet-close").addClass("baseSet-open")
    })

    $(".dynamic-effect a").each(function() {
        $(this).click(function(){
            $("#dynamicEffect").val($(this).attr('effect'));
        });
    });

    $(".checked").click(function(){
        if($(this).hasClass('current'))  {
            $(this).find('input').css({'background-color': '#daf9e5'});
        } else {
            $('#linkShow').css({'background-color': '#fff'});
        }
    });
    $("#linkShow").blur(function(){
        $(this).css({'background-color': '#fff'});
    });

    var $rad=$(".custom-ulp").find(".first-radio");
    var $rahover=$(".custom-ulp");
    $rad.live('click',function(){
        $(this).addClass("current");
        $(this).parents(".radios-module1").siblings().find(".first-radio").removeClass("current");
    })
    $rahover.live('mousemove',function(){
        $(this).find(".music_name").css({color:"#16ab4f"})
        $(this).find(".music_listen").css({display:"block"})
    })
    $rahover.live('mouseleave',function(){
        $(this).find(".music_name").css({color:"#2a2e35"})
        $(this).find(".music_listen").css({display:"none"})
    })
});
</script>


<script>
    //实例化文章内容弹出框富文本编辑器
    var options = {
        imagePath:"http://img.fcstatic.naryou.cn/img/",
        imageManagerPath:"",
        imageUrl: "/static/new_ui/js/ueditor/jsp/imageUp.jsp?merchantid=25526",
        imageManagerUrl: "/static/new_ui/js/ueditor/jsp/imageManager.jsp?merchantid=25526",
        catcherUrl: "/static/new_ui/js/ueditor/jsp/getRemoteImage.jsp?merchantid=25526",
        catcherPath:"http://img.fcstatic.naryou.cn/img/",
        initialFrameWidth:474,
        initialFrameHeight:496,
        focus:false,
        elementPathEnabled : false,
        autoHeightEnabled:false,
        wordCount:false,
        toolbars:[["bold","italic","underline","|","insertorderedlist","insertunorderedlist","|","insertimage","|","removeformat", 'fontfamily', 'fontsize',"forecolor","backcolor"]]
    };
    var ue = UE.getEditor('editor', options);

    /* 跳转设置关注微信链接 */
    function setWeixinAttentionUrl(){
        $("#form_task").attr("action", "/merse/estate/attention/to_set_attention.htm");
        $("#form_task").attr("method", "post");
        $("#form_task").submit();
    }

    function validateInput(obj, id, max, title) {
        obj = $(obj);
        var len = obj.val().length;
        $('#' + id + 'wronglength').html(len);
        if (len > 0 && len <= max) {
            errorTip(id, 'remove', '');
            return true;
        }
        if (len > max) {
            errorTip(id, 'add', title + '不能超过' + max + '个字符');
            return false;
        }
//        nullCheck(id);
    }

    /* 手动输入验证链接 */
    function validateUrl(obj, id, max, title) {
        $("#articleLinkType").val('OTHER');
        $("#otherLinkUrl").val($(obj).val());
        validateInput(obj, id, max, title);
    }

    /* 空值判断 */
    function nullCheck(id) {
        // 存在这个class才表示需要验证
        if($("#" + id + "wrongDiv").hasClass('input-cont2')) {
            if($("#" + id).val() == '') {
                errorTip(id, 'add', $("#" + id).attr('tip') + "不能为空");
                $("#" + id).focus();
                return false;
            }
        }
        return true;
    }

    /* 提交检查 */
    function submitCheck() {
        // 软文标题非空验证
        if(!nullCheck('taskName')) {
            return false;
        }
        // 软文标题长度验证
        if(!validateInput($("#taskName"), 'taskName', 30, '软文标题')) {
            return false;
        }
        // 验证宣传图
        if($("#postPic").attr('src') == '') {
            errorTip('postPic', 'add', '请上传宣传图');
            $("html,body").scrollTop(0);
            return false;
        }
        // 基础模板才验证输入框
        if($("#taskDisplayType").val() == 'BASIC_TEMPLATE') {
            //判断文章内容（正文）是否填写
             if (!ue.hasContents()) {
                 errorTip('editor', 'add', "软文内容不能为空");
                 ue.focus();
                 // 滚动到最上面，加入一个定时器，监测编辑器文本变化，文本变化后删除定时器
                 $("html,body").scrollTop(0);
                 var c = setInterval(function(){
                     if(ue.hasContents()) {
                         errorTip('editor', 'remove', "");
                         clearInterval(c);
                     }
                 },500);
                 return false;
             }
        } else {
            // 验证多媒体图片
            if($("#multiPicList input").length == 0) {
                errorTip('multiPic', 'add', '请选择需要添加的图片');
                $("html,body").scrollTop(150);
                return false;
            }
        }

        // 验证链接非空
        if(!nullCheck('linkShow')) {
            return false;
        }

        // 验证链接长度
        if(!validateInput($("#linkShow"), 'linkShow', 250, '链接地址')) {
            return false;
        }

        // 验证购房币数量
        if(!nullCheck('money')) {
            return false;
        }
        // 验证购房币数量长度验证
        if(!validateInput($("#money"), 'money', 6, '购房币数量')) {
            return false;
        }
        // 验证购房币为数字
        if(!checkGoldNum($("#money").val())) {
            return false;
        }
        // 验证音乐
        if($("#needMusic").val() == '1') {
            if(!checkChoose()) {
                return false;
            }
        }
        // 验证分享信息
        if(!checkPicInfo()) {
            return false;
        }
        // 分享标题验证
        if(!validateInput($("#shareTitle"), 'shareTitle', 26, '分享标题')) {
            return false;
        }
        return true;
    }

    /* 验证购房币为整数 */
    function checkGoldNum(value) {
        if(value > 0) {
            var regExp = /^[0-9]{1,}$/;
            if(!regExp.test(value)) {
                errorTip('money', 'add', '购房币必须为整数');
            }
            return regExp.test(value);
        }
        errorTip('money', 'add', '购房币必须大于0');
        return false;
    }

    /* 分享信息验证 */
    function checkPicInfo() {
        // 验证图片
        if($("#sharePic").val() == '') {
            $("#sharePicSpan").addClass('in-text2');
            $("#shareTitlewrong").html('分享图片不能空');
            return false;
        }
        // 验证分享标题
        if($("#shareTitle").val() == '') {
            $("#shareTitle").addClass('in-text2');
            $("#shareTitlewrong").html('分享标题不能空');
            $("#shareTitle").focus();
            return false;
        }
        return true;
    }

    /* 错误提示 */
    function errorTip(id, type, error) {
        if(type == 'add') {
            $("#" + id + "wrongDiv").addClass('wrong');
            $("#" + id + "wrong").html(error);
            $("#" + id).focus();
        } else {
            $("#" + id + "wrongDiv").removeClass("wrong");
            $("#" + id + "wrong").html('');
        }
    }
</script>
<script>
    /**文件上传代码--开始*/
    $(function(){

        /* 初始化音乐上传控件 */
        ajaxMusicUpload({
            uploadUrl:'/upload/MUSIC',
            onComplete:function(data){
                if (data.success) {
                    saveResult(1,data.msg);
                    var html = '<li class="radios-module1 custom-ulp rule_set_radio" id="music' + data.musicId + '" onclick="setUrl(this)" musicChooseId="' + data.musicId + '" link="' + data.wapPath + '">';
                    html += '<a class="radios first-radio" href="javascript:void(0);">';
                    html += '<span></span>&nbsp;<span class="music_name">' + data.musicName + '</span></a>';
                    html += '<span class="music_listen">';
                    html += '<a href="' + data.wapPath + '" target="_blank" class="color-green" link="' + data.wapPath + '">试听</a> | <a class="color-red" style="cursor: pointer;" href="javascript:;" musicName="' + data.musicName + '" musicId="' + data.musicId + '" onclick="delMusic(this)">删除</a></span>';
                    $("#music_list").append(html);
                } else {
                    saveResult(0,data.msg);
                }
                $(".upload-file").val('');
            }
        });

        var options = {
            uploadUrl : "",  //统一配置上传图片的路径
            uploadInputName : 'filedata', //后台接收文件的名称
            uploadParent:function(imgobj,optionType){
                if($(imgobj).attr("src")==""){
                    return;
                }
                if(optionType==0){
                    // 上传宣传图
                    $("#imgPic").attr("src", $(imgobj).attr("src"));
                    $("#imgPic").parent().removeClass("none");
                }else if(optionType==1){
                    // 上传多媒体图
                    var td = '<td class="template-img-box">';
                    td += '<div class="media-template-img"><img id="multiShow' + index + '" src="' + $(imgobj).attr("src") + '" alt=""/></div>';
                    td += '<div class="media-template-edit">';
                    td += '<a href="javascript:void(0);" index="' + index + '" class="move-top green-color">置顶</a>';

                    td += '<a data-toggle="modal" class="green-color" href="#uploadImgPopup" style="position:relative;" onclick="getIndex(' + index + ')">替换';
                    td += '<span class="upload-pic-box" style="width: 39px; height: 17px; position: absolute; left: 64px; top: 1px;">';
                    td += '<i class="upload-pic-btn naryou-upload upload-pic replace-pic" index="' + index + '"';
                    td += ' style="width: 39px; height: 17px; border: none; background: none;"';
                    td += '	canDelete="deleteValue" required="true"';
                    td += ' data-options="{uploadUrl:\'/upload/MULTI_MEDIA/img/\', canCrop: true, cropWidth: 600,optionType:2, cropHeight:1000,size:1048576}">';
                    td += '<input type="hidden" class="path" value=""/> ';
                    td += '<img id="hiddenShow' + index + '" src="'+$(imgobj).attr("src")+'" style="display: none">';
                    td += '</i>';
                    td += '</span>';
                    td += '</a>';
                    td += '<a href="javascript:void(0);" index="' + index + '" class="remove red-color">删除</a>';
                    td += '</div>';
                    td += '</td>';
                    $("#picList").append(td);
                }else if(optionType==2){
                    // 替换多媒体图
                    var realIndex = $("#realIndex").val();
                    $("#multiShow" + realIndex).attr('src', $(imgobj).attr("src"));
                    $("#hiddenShow" + realIndex).attr('src', $(imgobj).attr("src"));
                    $("#multi" + realIndex).val($(imgobj).attr("src"));
                }else if(optionType==3){
                    // 上传分享到朋友圈显示图片
                    $("#sharePicShow").attr('src', $(imgobj).attr("src"));
                }
            },
            onSelect:function(){
                $(".btn-success").addClass("submitBtn");
            }
        };
        uploadDialogTools.initUploadOptions(options);  //初始化上传参数
        uploadDialogTools.init(); //初始化上传图片按钮
        uploadDialogTools.bindOnBeforeShowDialog(beforeSelected); //绑定显示上传弹出层之前的回调事件（可选）
        uploadDialogTools.bindOnSelected(selected); //绑定上传对话框点确认按钮之后的回调事件（可选）
    });

    var index = 0; // 用于标记多媒体图片相对路径排序位置
    /**
     *   确认上传成功之后设置图片描述信息的值
     *   uploadArea为点击的上传的Dom元素（jQuery对象）
     */
    function selected(uploadArea){

        var img = $(uploadArea).find("img");
        img.siblings("i").remove();
        img.after('<i class="delete_img_btn"></i>');

        //获取上传图片的全路径
        var url = $(uploadArea).find("img").attr("src");
        if(url){
            //移除默认图片样式，将src设置为上传图片的路径
            $("#wapVal_zst").attr("src",url);
        }

        // 只有多媒体图片才放入多媒体图列表中
        if($(uploadArea).hasClass('multi-pic')) {
            var html = '<input type="hidden" id="multi' + index + '" name="multiPic" value="' + $("#multiPic").val() + '">';
            $("#multiPicList").append(html);
            // 清除多媒体图错误提示样式
            errorTip('multiPic', 'remove', '');
            index ++;
        } else if($(uploadArea).hasClass('replace-pic')) {
            var ind = $(uploadArea).attr('index');
            $("#multi" + ind).val($(uploadArea).find("input").val());
        } else if($(uploadArea).hasClass('share-pic')) {
            $("#share-pic").attr('src', $("#sharePicShow").attr('src'));
            // 清除分享信息的错误提示样式
            $("#sharePicSpan").removeClass('in-text2');
            $("#shareTitlewrong").html('');
        } else if($(uploadArea).hasClass('post-pic')) {
            $("#postPic").attr('src', $("#imgPic").attr('src'));
            errorTip('postPic', 'remove', '');
        }
    }
    /**
     *   在显示上传对话框之前初始化图片描述信息
     *   uploadArea为点击的上传的Dom元素（jQuery对象）
     */
    function beforeSelected(uploadArea){
        $("#txtImageContent").val(uploadArea.find(".content").val());
    }
    $(function(){
        $(".dropdown").dropdown();
        _tab({
            tabNav: '.tabTest li',
            tabCon: '.tabContent',
            handle: 'click',
            curClass: 'on'
        });
        $(".i-switch").click(function(){
            if($(this).hasClass("f-close")){
                $(this).removeClass("f-close");
            }else{
                $(this).addClass("f-close");
            }
        });
        $(".layRedPacketA").click(function(){
            var lVar=$(this).attr("title");
            var lID="#"+lVar+"-layer";
            $(lID).show();
        });
        $(".closeBtn").click(function(){
            $("#layRedPacketA-layer").hide();
        });

        /* 基础模板预览 */
        $("#basicPreShow").click(function(){
            previewWap();
        });
        /* 幻灯片预览 */
        $("#mediaPreShow").click(function(){
            previewWap();
        });
    });
    /**文件上传代码--结束*/

    /* 置顶 */
    $(".move-top").live("click",function(){
        var indexNum = $(this).attr('index');
        $(this).parents('td').prependTo($(this).parents('tr'));
        $("#multi" + indexNum).prependTo($("#multiPicList"));
    });

    $(".remove").live("click",function(){
        var indexNum = $(this).attr('index');
        $(this).parents('td').remove();
        $("#multi" + indexNum).remove();
    })

    /* 设置点击需要替换的多媒体图的标记 */
    function getIndex(value) {
        $("#realIndex").val(value);
    }

    /* 显示隐藏音乐设置 */
    function checkMusicUrlDiv(obj) {
        if($(obj).hasClass('baseSet-close')) {
            $("#musicDiv").show();
            $("#needMusic").val(1);
        } else {
            $("#musicDiv").hide();
            $("#needMusic").val(0);
        }
    }

    //保存软文
    function saveTask() {
        if (!submitCheck()) {
            return;
        }
        $.ajax({
            url:'/merse/estate/task/building_task/save.htm',
            type:'post',
            data:$('#form_task').serialize(),
            success:function(data) {
                if (data.success) {
                    saveResult(1,data.msg,function(){
                        window.location.href = "/merse/estate/task/building_task/";
                    });
                } else {
                    saveResult(0,data.msg);
                }
            }
        });
    }

    /* 选择微官网链接 */
    function chooseLink(obj) {
        $("#articleLinkType").val('WAP');
        $('#linkShow').css({'background-color': '#fff'});
        $("#linkShow").val($(obj).html());
        $("#wapLinkUrl").val($(obj).attr('value'));
    }

    /* 设置展示方式 */
    function setDisplayType(value) {
        $("#taskDisplayType").val(value);
    }

    /* 选择多媒体图 */
    function selectMultiPic() {
        if($("#multiPicList input").length >= 10) {
            saveResult(0,'幻灯片图片最多10张');
            return;
        }
        $(".multi-pic").trigger("click");
    }

    /* 上传音乐 */
    function uploadMusic() {
        if($("#music_list li").length >= 10) {
            saveResult(0, '音乐最多上传10首!');
            return;
        }
        $(".upload-file").trigger("click");
    }

    /* 检查选择音乐 */
    function checkChoose() {
        var array = $("#music_list li").find("a");
        for(var i=0;i<array.length;i++){
            if($(array[i]).hasClass('current')) {
                return true;
            }
        }
        $("#musicDiv").css({borderColor:'#ea3a3c'});
        $("#musicDivwrong").html('请选择或上传音乐');
        return false;
    }

    /* 设置音乐url */
    function setUrl(obj) {
        $("#musicUrl").val($(obj).attr('link'));
        $("#musicChooseId").val($(obj).attr('musicChooseId'));
        $("#musicDiv").css({borderColor:'#ffffff'});
        $("#musicDivwrong").html('');
    }

    /* 预览需要验证的信息 */
    function previewCheck() {
        // 软文标题非空验证
        if(!nullCheck('taskName')) {
            return false;
        }
        // 软文标题长度验证
        if(!validateInput($("#taskName"), 'taskName', 30, '软文标题')) {
            return false;
        }
        // 基础模板才验证输入框
        if($("#taskDisplayType").val() == 'BASIC_TEMPLATE') {
            //判断文章内容（正文）是否填写
            if (!ue.hasContents()) {
                errorTip('editor', 'add', "软文内容不能为空");
                ue.focus();
                // 滚动到最上面，加入一个定时器，监测编辑器文本变化，文本变化后删除定时器
                $("html,body").scrollTop(0);
                var c = setInterval(function(){
                    if(ue.hasContents()) {
                        errorTip('editor', 'remove', "");
                        clearInterval(c);
                    }
                },500);
                return false;
            }
        } else {
            // 验证多媒体图片
            if($("#multiPicList input").length == 0) {
                errorTip('multiPic', 'add', '请选择需要添加的图片');
                $("html,body").scrollTop(150);
                return false;
            }
        }
        return true;
    }

    /* 预览微官网效果 */
    function previewWap() {
        if (!previewCheck()) {
            return;
        }
        openPostWindow('/merse/estate/task/preview', $('#form_task').serialize(), $("#taskName").val());
    }

    /* 以post方式新开窗口 */
    function openPostWindow(url, data, name) {
        var formTask = $(form_task).clone();
        formTask.find('#taskName').html($("#taskName").val());
        formTask.find('#ueditor_textarea_content').html(ue.getContent());
        var tempForm = formTask[0];
        tempForm.id = "tempForm1";
        tempForm.method = "post";
        tempForm.action = url;
        tempForm.target = name;

        /*data = decodeURIComponent(data);
         var dataArray = data.split('&');
         for (var i=0;i<dataArray.length;i++){
         var dataInfo = dataArray[i];
         var hideInput = document.createElement("input");
         hideInput.type = "hidden";
         hideInput.name = dataInfo.split("=")[0];
         hideInput.value = dataInfo.split("=")[1];
         tempForm.appendChild(hideInput);
         }*/

        if (window.attachEvent) {
            tempForm.attachEvent("onsubmit", function() {
                openWindow(name);
            });
        }
        else {
            tempForm.addEventListener("onsubmit", function() {
                openWindow(name);
            }, false);
        }
        document.body.appendChild(tempForm);
        fireEvent(tempForm, "onsubmit");
        tempForm.submit();
        document.body.removeChild(tempForm);
    }

    var fireEvent = function(element,event){
        if (document.createEventObject){
            // IE浏览器支持fireEvent方法
            var evt = document.createEventObject();
            return element.fireEvent('on'+event,evt)
        }
        else{
            // 其他标准浏览器使用dispatchEvent方法
            var evt = document.createEvent( 'HTMLEvents' );
            // initEvent接受3个参数：
            // 事件类型，是否冒泡，是否阻止浏览器的默认行为
            evt.initEvent(event, true, true);
            return !element.dispatchEvent(evt);
        }
    };

    /* 新开窗口 */
    function openWindow(name) {
        window.open('about:blank', name, 'height=505, width=320');
    }

    /* 调用删除确认弹窗，并设置相关参数  */
    function delMusic(obj) {
        var musicId = $(obj).attr('musicId');
        var musicName = $(obj).attr('musicName');
        $("#musicName").html(musicName);
        $("#musicId").val(musicId);
        $("#delete").modal('show');
    }

    function submitDel() {
        var id = $("#musicId").val();
        if(id == '') {
            saveResult(0, '删除失败!');
            $("#delete").modal('hide');
        }
        $.ajax({
            url:'/merse/music/delete_music/' + id,
            type:'post',
            success:function(data) {
                if(data.success) {
                    $("#music" + id).remove();
                    $("#delete").modal('hide');
                    saveResult(1, data.msg);
                } else {
                    saveResult(0, data.msg);
                }
            }
        })
    }
</script>